
package org.come.mouslisten;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.ShoppingBuyJpanel;
import org.come.entity.Goodstable;
import org.come.model.Shop;
import org.come.until.MessagrFlagUntil;
import org.come.until.UserMessUntil;

public class ShopMouslisten implements MouseListener {
	private int shopPlace;
	private ShoppingBuyJpanel shoppingBuyJpanel;

	public ShopMouslisten(int shopPlace, ShoppingBuyJpanel shoppingBuyJpanel) {
		this.shoppingBuyJpanel = shoppingBuyJpanel;
		this.shopPlace = shopPlace;
	}

	@Override
    public void mouseClicked(MouseEvent e) {
	}

	@Override
    public void mousePressed(MouseEvent e) {
		Shop shop = this.shoppingBuyJpanel.getShop(this.shopPlace);
		if (shop != null) {
			this.shoppingBuyJpanel.xuanzhong(shop, this.shopPlace);
		}

	}

	@Override
    public void mouseReleased(MouseEvent e) {
	}

	@Override
    public void mouseEntered(MouseEvent e) {
		MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE12);
		Shop shop = this.shoppingBuyJpanel.getShop(this.shopPlace);
		if (shop != null) {
			String text = shop.getShoptext();
			Goodstable goodstable = UserMessUntil.getgoodstable(shop.getShopiid());
			if (goodstable != null && goodstable.getType() == 112) {
				shop.setValue(goodstable.getValue());
			}
			shop.setQualiy(goodstable.getQuality());
			this.shoppingBuyJpanel.PaintingText(this.shopPlace);
			ZhuFrame.getZhuJpanel().creatgoodtext(shop);
		}

	}

	@Override
    public void mouseExited(MouseEvent e) {
		MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
		this.shoppingBuyJpanel.ClearText(this.shopPlace);
		ZhuFrame.getZhuJpanel().cleargoodtext();
	}

	public int getShopPlace() {
		return this.shopPlace;
	}

	public void setShopPlace(int shopPlace) {
		this.shopPlace = shopPlace;
	}
}
